package com.dhkj.printlib.model;

import com.dhkj.printlib.entity.Foods;
import com.dhkj.printlib.entity.ThreePrintVo;
import com.dhkj.printlib.utils.PrintUtil;
import com.dhkj.printlib.utils.sunmi.AidlUtil;

import java.io.IOException;

/**
 * 支付后的模型
 */
public class PayPrintModel {


    //
    public static void prints(ThreePrintVo threePrintVo) {
        try {
            PrintUtil pUtil = new PrintUtil();

            // 店铺名 居中 放大
            pUtil.printAlignment(1);
            pUtil.printLargeText(threePrintVo.getTitle());
            pUtil.printLine();
            pUtil.printAlignment(0);
            pUtil.printLine();
            pUtil.printTwoColumn("时间:", threePrintVo.getOperaTime());
            pUtil.printLine();
            pUtil.printTwoColumn("订单号:", threePrintVo.getOrders());
            pUtil.printLine();
//            if (printVO.getType()==2){
//                pUtil.printTwoColumn("IC卡姓名:", printVO.getCardname());
//            }
            pUtil.printTwoColumn("收款人:", threePrintVo.getOperator());
            pUtil.printLine();
            // 分隔线
            pUtil.printDashLine();
            pUtil.printLine();
            //打印商品列表
            pUtil.printThreeColumn("商品", "数量", "小计");
            pUtil.printLine();
            for (Foods goo : threePrintVo.getFoods()) {
                pUtil.printThreeColumn(goo.getName(), "x"+String.valueOf(goo.getNum()), String.valueOf(goo.getAmount()));
            }
            pUtil.printDashLine();
            pUtil.printLine();

            pUtil.printTwoColumn("合计数量:", threePrintVo.getCount());
            pUtil.printLine();

            pUtil.printTwoColumn("合计金额:", threePrintVo.getAmount());
            pUtil.printLine();
            pUtil.printTwoColumn("上期金额:", threePrintVo.getLastPrice());
            pUtil.printLine();
            pUtil.printTwoColumn("消费余额:", threePrintVo.getNowPrice());
            pUtil.printLine();
            pUtil.printTwoColumn("消费方式:", threePrintVo.getPayType());
            pUtil.printLine();
//            if (printVO.getType()==2) {
//                if (printVO.getBt() == 0) {
//                    pUtil.printTwoColumn("支付方式：:", "IC卡支付(自购)");
//                    pUtil.printTwoColumn("上次自购余额：:", String.valueOf(printVO.getLastje()));
//                    pUtil.printTwoColumn("本次自购余额：:", String.valueOf(printVO.getJe()));
//                    pUtil.printTwoColumn("本次补贴余额：:", String.valueOf(printVO.getJe2()));
//                } else {
//                    pUtil.printTwoColumn("支付方式：:", "IC卡支付(补贴)");
//                    pUtil.printTwoColumn("上次补贴余额：:", String.valueOf(printVO.getLastje()));
//                    pUtil.printTwoColumn("本次补贴余额：:", String.valueOf(printVO.getJe2()));
//                    pUtil.printTwoColumn("本次自购余额：:", String.valueOf(printVO.getJe()));
//                }
//            }
//            if(printVO.getType()==1){
//                pUtil.printTwoColumn("支付方式：:", "IC卡支付");
//            }
//            if(printVO.getType()==3){
//                pUtil.printTwoColumn("支付方式：:", "扫码支付");
//            }


            pUtil.printDashLine();
            //打印页脚
            if (threePrintVo.getFoot() != null && !threePrintVo.getFoot().equals("")) {
                pUtil.printLargeText(threePrintVo.getFoot());
            }
            pUtil.printLine(2);
            pUtil.printQZ();
            AidlUtil.getInstance().sendRawData(pUtil.getOutbyte());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
